package com.imooc.collection

object ListApp extends App{

  val l = List(1,2,3,4,5)
  println(l)
  println(l.head)
  println(l.tail)

  val l2 = 1 :: Nil
  println(l2)

  val l3 = 2 :: l2
  println(l3)

  val l4 = 1 :: 2 :: 3 :: Nil
  println(l4)

  val l5 = scala.collection.mutable.ListBuffer[Int]()
  println(l5)
  println(l5 += (2,3,5))

  l5 -= 2
  l5 -= (1,4)


  def sum(nums:Int*):Int = {
    if(nums.length == 0)
      0
    else
      nums.head + sum(nums.tail:_*)
  }

  println(sum())
  println(sum(1,2,3,4))


  val set = scala.collection.mutable.Set[Int]()

  set += 1
  set += (1,1,3,4,2)

  println(set)





}
